package com.lagou.bean;

import com.lagou.utils.HttpProtocolUtil;

import java.io.OutputStream;
import java.io.Serializable;

/**
 * 封装response
 */
public class HttpResponse implements Serializable {

    public final OutputStream outputStream;

    public HttpResponse(OutputStream outputStream) {
        this.outputStream = outputStream;
    }

    public OutputStream getOutputStream() {
        return outputStream;
    }

    public void outputContent(String content) throws Exception {
        int length = content.length();
        content = HttpProtocolUtil.getHttpHeader200(length) + content;
        outputStream.write(content.getBytes());
    }
}
